#!/bin/bash
source /etc/profile
. $BEETLE_SHELL_PATH/error.sh

start(){
    tomcatPath=/usr/local/winit_tomcat

    ps -ef |grep ${tomcatPath} | grep -v grep

    sleep 3

    cd ${tomcatPath} || error_exit

    bash tomcat.sh start centos /usr/local/java/jdk1.7.0_79 /usr/local/winit_tomcat 8081

    ps -ef |grep ${tomcatPath} | grep -v grep

    sleep 3

    tail-log api
}

stop(){
    tomcatPath=/usr/local/winit_tomcat

    ps -ef |grep ${tomcatPath} | grep -v grep

    sleep 3

    cd ${tomcatPath} || error_exit

    bash tomcat.sh stop centos /usr/local/java/jdk1.7.0_79 /usr/local/winit_tomcat 8081

    ps -ef |grep ${tomcatPath} | grep -v grep
}

restart(){
    stop
    sleep 3
    start
}

case "$1" in
    start)
        start ;;
    stop)
        stop ;;
    restart)
        restart ;;
    *)
    	echo "Usage: tomcat {start|stop|restart}"
    exit 1
esac
exit 0